#include<iostream>

using namespace std;

const int N = 55;
int a[N];
int all=0;
int b, c = 0;

int main()
{
	int n; cin >> n; int mi, ma;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		all += a[i];
	}
	 cin >> mi >> ma;
	if (all<mi * n || all>ma * n)
	{
		cout << -1; return 0;
	}
	for (int i = 1; i <= n; i++)
	{
		if (a[i] < mi) b += mi - a[i];
		else if (a[i] > ma) c += a[i] - ma;
	}
	cout << max(b,c);
	return 0;
}
